-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure DB connections are closed when we've finished with them #1619
Ensure DB connections are closed when we've finished with them #1619
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1619 +/- ##
=======================================
Coverage 62.94% 62.94%
=======================================
Files 187 187
Lines 12359 12359
=======================================
Hits 7779 7779
Misses 3896 3896
Partials 684 684 Continue to review full report at Codecov.
|
This is much simpler than a cache of DBs. I started going down that path but as always it's removing no-longer needed DBs from the cache that makes it more complicated. For now this will fix the leak and if we have a problem with opening and closing connections being too slow we can fix that then.
This is much simpler than trying to use a DB cache for it.
In the azuresqlaction, azuresqlmanageduser and azuresqluser reconcilers.
The ASO CI subscription can't create servers in eastus2 but westus2 is allowed at the moment.
650d598
to
ea608c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@matthchr @babbageclunk Is there already a timeline for the next release, which includes this fix? |
@johgoe There's no hard deadline but I would imagine sometime in the next week. Are you waiting for this change? (I assume yes given you're asking here). |
@matthchr Thank you for you fast reply. Currently we have to restart our PostgreSQL Server too often. We are happy to hear that the release should be available sometime next week. |
Closes #1576
What this PR does / why we need it:
Before this change, the different resources would leak database connections whenever they were reconciled. Add
defer db.Close()
to all of the places that open database connections so that they are closed at the end of the method.Special notes for your reviewer:
I started off making a cache to keep the
*sql.DB
s in so that they could be reused between reconciliations, but then the difficulty was ensuring we didn't keep the DBs in the cache indefinitely. One option was to hook up the database controller so it could remove the cached entry when the database was deleted, but that's quite fiddly architecturally. I also wrote some code to clear DBs from the cache if they haven't been requested after a fixed amount of time, which would work but would be really difficult to test (to an extent that is probably not worth it).How does this PR make you feel: